﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="CacheValue.cs" company="XamlNinja">
//   2011 Richard Griffin and Ollie Riches
// </copyright>
// <summary>
//   The caches are designed to be used with references types, this class is provided as a wrapper for value types which are to
//   be used as the value part of the key-value pair.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace WP7Contrib.Caching
{
    using Common;

    /// <summary>
    /// The caches are designed to be used with references types, this class is provided as a wrapper for value types which are to
    /// be used as the value part of the key-value pair.
    /// </summary>
    public sealed class CacheValue<T> : BaseModel where T : struct
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="CacheValue"/> class.
        /// </summary>
        public CacheValue()
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="CacheValue"/> class.
        /// </summary>
        /// <param name="value">
        /// The value.
        /// </param>
        public CacheValue(T value)
        {
            this.Value = value;
        }

        #endregion

        #region Properties

        /// <summary>
        /// Gets or sets CacheValue.
        /// </summary>
        public T Value { get; set; }

        #endregion

        #region Public Methods

        /// <summary>
        /// The get hash code.
        /// </summary>
        /// <returns>
        /// Returns the combined hash code of the properties of the class.
        /// </returns>
        public override int GetHashCode()
        {
            return this.CombineHashCodes(this.Value);
        }

        #endregion
    }
}